package day01.file;

import java.io.File;

/**
 * @ClassName Test2
 * @Description TODO
 * @Author 16433
 * @Date 2023/3/6 16:44
 * @Version 1.0
 *
 * 获取当前file目录下的所有子项,并且输出每个子项的名字和占用的空间大小
 **/
public class Test2 {
    public static void main(String[] args) {
        File dir = new File("./JSD2205_SE/src/day01/file");
        if(dir.isDirectory()){
            File[] subs = dir.listFiles();
            System.out.println("file目录下一共有"+subs.length+"个子项");
            for (int i = 0; i < subs.length; i++) {
                File sub = subs[i];
                System.out.println("文件名字为:"+sub.getName()+"---文件占用的空间大小:"+sub.length());
            }
        }
    }
}
